/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;

import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import org.hibernate.annotations.CacheConcurrencyStrategy;

/**
 *
 * @author Anthares
 */
@Entity
@Table(name = "TRAD_PROD")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TradProd.findAll", query = "SELECT t FROM TradProd t"),
    @NamedQuery(name = "TradProd.findById", query = "SELECT t FROM TradProd t WHERE t.tradProdPK.langId = :langId AND t.tradProdPK.prodId = :prodId"),
    @NamedQuery(name = "TradProd.findByLangId", query = "SELECT t FROM TradProd t WHERE t.tradProdPK.langId = :langId"),
    @NamedQuery(name = "TradProd.findByProdId", query = "SELECT t FROM TradProd t WHERE t.tradProdPK.prodId = :prodId"),
    @NamedQuery(name = "TradProd.findByLibelle", query = "SELECT t FROM TradProd t WHERE t.libelle = :libelle"),
    @NamedQuery(name = "TradProd.findByDescrip", query = "SELECT t FROM TradProd t WHERE t.descrip = :descrip")})
public class TradProd implements Serializable {
    private static final long serialVersionUID = 1L;

    @EmbeddedId
    protected TradProdPK tradProdPK;

    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(nullable = false, length = 255)
    private String libelle;

    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(nullable = false, length = 255)
    private String descrip;

    @JoinColumn(name = "PROD_ID", referencedColumnName = "PROD_ID", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Produit produit;

    @JoinColumn(name = "LANG_ID", referencedColumnName = "LANG_ID", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Langue langue;

    public TradProd() {
    }

    public TradProd(TradProdPK tradProdPK) {
        this.tradProdPK = tradProdPK;
    }

    public TradProd(TradProdPK tradProdPK, String libelle, String descrip) {
        this.tradProdPK = tradProdPK;
        this.libelle = libelle;
        this.descrip = descrip;
    }

    public TradProd(String langId, int prodId) {
        this.tradProdPK = new TradProdPK(langId, prodId);
    }

    public TradProdPK getTradProdPK() {
        return tradProdPK;
    }

    public void setTradProdPK(TradProdPK tradProdPK) {
        this.tradProdPK = tradProdPK;
    }

    public String getLibelle() {
        return libelle;
    }

    public void setLibelle(String libelle) {
        this.libelle = libelle;
    }

    public String getDescrip() {
        return descrip;
    }

    public void setDescrip(String descrip) {
        this.descrip = descrip;
    }

    public Produit getProduit() {
        return produit;
    }

    public void setProduit(Produit produit) {
        this.produit = produit;
    }

    public Langue getLangue() {
        return langue;
    }

    public void setLangue(Langue langue) {
        this.langue = langue;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (tradProdPK != null ? tradProdPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TradProd)) {
            return false;
        }
        TradProd other = (TradProd) object;
        if ((this.tradProdPK == null && other.tradProdPK != null) || (this.tradProdPK != null && !this.tradProdPK.equals(other.tradProdPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Model.TradProd[ tradProdPK=" + tradProdPK + " ]";
    }
    
}
